@model ExpertSMS.Models.Unit
@{
    ExpertSMS.Models.Product product = (ExpertSMS.Models.Product)ViewBag.Product;
}
@* This partial view defines form fields that will appear when creating and editing entities *@

<div class="editor-label">
    @Html.LabelFor(model => model.Name)
</div>
<div class="editor-field">
    @Html.EditorFor(model => model.Name)
    @Html.ValidationMessageFor(model => model.Name)
</div>

<div class="editor-label">
    @Html.LabelFor(model => model.ConvertingFactor)
</div>
<div class="editor-field">
    @Html.EditorFor(model => model.ConvertingFactor)
    @Html.ValidationMessageFor(model => model.ConvertingFactor)
</div>

<div class="editor-label">
    @Html.LabelFor(mode => mode.ProductID)
</div>
<div class="editor-field">
    @Html.Encode(product.Name)
    @Html.HiddenFor(model => model.ProductID, product.ProductID)
    @Html.ValidationMessageFor(model => model.ProductID)
</div>
<div class="editor-label">
    @Html.LabelFor(model => model.ParentUnitID)
</div>
<div class="editor-field">
    @Html.DropDownListFor(model => model.ParentUnitID, ((IEnumerable<ExpertSMS.Models.Unit>)ViewBag.PossibleParentUnits).Select(option => new SelectListItem {
        Text = (option == null ? "None" : option.Name), 
        Value = option.UnitID.ToString(),
        Selected = (Model != null) && (option.UnitID == Model.ParentUnitID)
    }))
    @Html.ValidationMessageFor(model => model.ParentUnitID)
</div>
